package controller;

import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import model.GameClient;

public class KeyboardListener implements KeyListener{
	
	private GameClient gameClient;
	
	public KeyboardListener(GameClient gameClient){
		super();
		this.gameClient = gameClient;
	}

	public void keyReleased(KeyEvent e) {
		if (gameClient.isStarted() == true){
			int keyCode = e.getKeyCode();
		    switch(keyCode) { 
		        case KeyEvent.VK_UP:
		        	System.out.println("You pressed UP");
		        	gameClient.move(0);

		            break;
		        case KeyEvent.VK_DOWN:
		        	System.out.println("You pressed DOWN");
		        	gameClient.move(1);
		        	
		            break;
		        case KeyEvent.VK_LEFT:
		        	System.out.println("You pressed LEFT");
		        	gameClient.move(2);
		        	
		            break;
		        case KeyEvent.VK_RIGHT :
		        	System.out.println("You pressed RIGHT");
		        	gameClient.move(3);
		        	
		            break;
		        case KeyEvent.VK_ESCAPE :
		        	System.out.println("You pressed ESCAPE");
		        	gameClient.teleport();
		        	
		            break;
		     }
		}
	}
	
	public void keyTyped(KeyEvent e) {}
	public void keyPressed(KeyEvent e) {}

}
